package com.roc.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.roc.dao.DaoException;
import com.roc.dao.IRiskDao;
import com.roc.pojo.Operators;
@Repository
public class RiskDaoImpl   implements IRiskDao {
	private Logger logger = LogManager.getLogger(RiskDaoImpl.class);
	//@Autowired
	@Resource(name = "sessionFactoryDg")
	SessionFactory sessionFactoryDg;

	@SuppressWarnings({ "finally", "unchecked" })
	@Override
	public List<Operators> queryRiskList() throws DaoException {
		List<Operators> riskList=new ArrayList<Operators>();
		Session session=null;
		try {
			 session = sessionFactoryDg.openSession();
			String hql="from Operators where status= '00'  and ( roleType='12' OR  roleType='13') ";
			Query query=session.createQuery(hql);
			riskList=query.list();
		} catch (HibernateException e) {
			e.printStackTrace();
			logger.debug(e.getMessage(), e);
			throw new DaoException("查询风控信息出错");
		}finally {
			if(session!=null){
				session.close();
			}
		return riskList;
	}
	}
	}
